package com.powerbank.ordercenter.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.powerbank.common.dto.CreateOrderRequest;
import com.powerbank.common.dto.OrderDTO;
import com.powerbank.common.dto.ReturnOrderRequest;
import com.powerbank.common.result.PageResult;
import com.powerbank.common.result.Result;
import com.powerbank.ordercenter.entity.Order;

import java.util.List;

/**\n * 订单服务接口\n */
public interface OrderService extends IService<Order> {

    /**\n     * 创建订单\n     */
    Result<OrderDTO> createOrder(CreateOrderRequest request);

    /**\n     * 支付订单\n     */
    Result<Void> payOrder(String orderNo, String paymentId);

    /**\n     * 开始使用\n     */
    Result<Void> startOrder(String orderNo);

    /**\n     * 归还设备\n     */
    Result<OrderDTO> returnOrder(ReturnOrderRequest request);

    /**\n     * 取消订单\n     */
    Result<Void> cancelOrder(String orderNo, String reason);

    /**\n     * 根据订单号查询订单\n     */
    Result<OrderDTO> getOrderByNo(String orderNo);

    /**\n     * 根据用户ID查询订单列表\n     */
    Result<PageResult<OrderDTO>> getUserOrders(Long userId, Integer page, Integer size);

    /**\n     * 根据设备ID查询当前订单\n     */
    Result<OrderDTO> getCurrentOrderByDevice(Long deviceId);

    /**\n     * 查询用户活跃订单\n     */
    Result<List<OrderDTO>> getUserActiveOrders(Long userId);

    /**\n     * 处理超时订单\n     */
    void handleOverdueOrders();

    /**\n     * 处理未支付过期订单\n     */
    void handleUnpaidExpiredOrders();

    /**\n     * 计算订单费用\n     */
    Result<OrderDTO> calculateOrderFee(String orderNo);
    
    /**\n     * 在事务中更新订单状态\n     */
    boolean updateOrderStatusInTransaction(Long orderId);
    
    /**\n     * 获取订单状态\n     */
    String getOrderStatus(Long orderId);
}